dart enum

132

enum CarType {
  sedan,
  suv,
  truck
}

class CarHireCompany {
  CarType storageType;

  CarHireCompany({@required this.storageType});
}
enum Status { 
   none, 
   running, 
   stopped, 
   paused 
}  
void main() { 
   print(Status.values); 
   Status.values.forEach((v) => print('value: $v, index: ${v.index}'));
   print('running: ${Status.running}, ${Status.running.index}'); 
   print('running index: ${Status.values[1]}'); 
}

Comments

Submit
0 Comments